package com.ntschy.common.core.entity.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SysCategoryEnum implements IEnum<Integer> {
    XTJSF(0, "系统建设方"),
    SGDW(1, "施工单位"),
    JLDW(2, "监理单位"),
    XJDW(3, "巡检单位"),
    YHDW(4, "养护单位");

    private final int value;

    //@JsonValue
    private final String desc;

    SysCategoryEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    public String getDesc() {
        return desc;
    }

    @JsonCreator
    public static SysCategoryEnum getCategoryFromValue(int value) {
        for (SysCategoryEnum category : SysCategoryEnum.values()) {
            if(category.getValue() == value) {
                return category;
            }
        }
        return null;
    }
}
